﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
/*using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;*/
using System.Xml.Linq;
using System.Net.Mail;
using System.IO;

/// <summary>
/// Descripción breve de SendMail
/// </summary>
public class SendMail
{
    #region Varibles
    string _Errores;
    #endregion
 
    public SendMail()
    {
    }
    //Metodo para mandar nuestro Correo Electronico
    public bool Sendmail(string correo, string asunto, string body)
    {
        string[] Destinatario = correo.Split(';');
        MailMessage Mail = new MailMessage();
        Mail.From = new MailAddress("soren.corona@ctin.com.mx");
        foreach (string cliente in Destinatario)
        {
            Mail.To.Add(new MailAddress(cliente));
        }
        Mail.Subject = asunto;
        Mail.Body = body;
        Mail.IsBodyHtml = false;
        Mail.Priority = MailPriority.Normal;

        /*if (Archivo.HasFile)
        {
            string fileName = Path.GetFileName(Archivo.PostedFile.FileName);
            Attachment myAttachment = new Attachment(Archivo.FileContent, fileName);
            Mail.Attachments.Add(myAttachment);
        } */
        SmtpClient smtp = new SmtpClient();

        smtp.Host = "smtp.ctin.com.mx";
        smtp.Credentials = new System.Net.NetworkCredential("soren.corona@ctin.com.mx", "QtZG4G1e");
        smtp.EnableSsl = false;
        try
        {
            smtp.Send(Mail);
            return true;
        }
        catch (Exception ex)
        {
            _Errores = ex.Message;
            return false;
        }
    }
    
    public string Errores
    {
        get { return _Errores; }
    }
}
